<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="com.example.domain.User" %>
<%
    // 检查用户是否已登录
    User currentUser = (User) session.getAttribute("user");
    if (currentUser == null) {
        response.sendRedirect("../auth/login.jsp");
        return;
    }

    Integer orderId = (Integer) session.getAttribute("orderId");
    if (orderId == null) {
        response.sendRedirect("../view/cart.jsp");
        return;
    }
    
    // 移除session中的orderId
    session.removeAttribute("orderId");
%>
<html>
<head>
    <title>订单支付成功 - 购物网</title>
    <link rel="stylesheet" href="../assets/css/styles.css">
    <style>
        /* 页面头部 */
        .page-header {
            background: linear-gradient(135deg, var(--success-color) 0%, #20c997 100%);
            color: white;
            padding: 2rem 0;
            margin-bottom: 2rem;
            box-shadow: var(--shadow-md);
        }
        
        .page-title {
            text-align: center;
            margin: 0;
            font-size: 2.5rem;
            font-weight: 600;
            text-shadow: 0 2px 4px rgba(0,0,0,0.2);
        }
        
        .page-subtitle {
            text-align: center;
            margin-top: 0.5rem;
            font-size: 1.1rem;
            opacity: 0.9;
        }
        
        .breadcrumb {
            display: flex;
            justify-content: center;
            margin-top: 1rem;
            font-size: 0.9rem;
        }
        
        .breadcrumb a {
            color: rgba(255, 255, 255, 0.8);
            text-decoration: none;
            transition: var(--transition);
        }
        
        .breadcrumb a:hover {
            color: white;
            text-decoration: underline;
        }
        
        .breadcrumb span {
            margin: 0 0.5rem;
            opacity: 0.8;
        }
        
        /* 成功卡片样式 */
        .success-card {
            background: var(--white-color);
            border-radius: var(--border-radius-lg);
            box-shadow: var(--shadow);
            padding: 3rem;
            text-align: center;
            margin-bottom: 2rem;
            position: relative;
            overflow: hidden;
            animation: fadeIn 0.7s ease-out;
        }
        
        .success-card:hover {
            box-shadow: var(--shadow-md);
        }
        
        /* 成功图标样式 */
        .success-icon {
            font-size: 6rem;
            color: var(--success-color);
            margin-bottom: 1.5rem;
            display: inline-block;
            animation: successPop 0.6s ease-out;
            text-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
            position: relative;
        }
        
        .success-icon::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 120%;
            height: 120%;
            background: var(--success-color);
            opacity: 0.15;
            border-radius: 50%;
            transform: translate(-50%, -50%);
            animation: pulse 2s ease-out infinite;
            z-index: -1;
        }
        
        /* 标题和文本样式 */
        .success-title {
            font-size: 1.8rem;
            font-weight: 600;
            color: var(--gray-800);
            margin-bottom: 1rem;
            animation: fadeIn 0.5s ease-out 0.2s both;
        }
        
        .success-message {
            font-size: 1.1rem;
            color: var(--gray-600);
            margin-bottom: 0.75rem;
            animation: fadeIn 0.5s ease-out 0.4s both;
        }
        
        .order-id {
            font-weight: bold;
            color: var(--primary-color);
            letter-spacing: 0.5px;
        }
        
        .success-subtext {
            color: var(--gray-500);
            margin-bottom: 2rem;
            animation: fadeIn 0.5s ease-out 0.6s both;
        }
        
        /* 按钮组样式 */
        .success-actions {
            display: flex;
            justify-content: center;
            gap: 1rem;
            margin-top: 2rem;
            animation: fadeIn 0.5s ease-out 0.8s both;
        }
        
        .success-actions .btn {
            padding: 0.875rem 1.5rem;
            font-size: 1rem;
            font-weight: 500;
            border-radius: var(--border-radius);
            transition: var(--transition);
            position: relative;
            overflow: hidden;
            z-index: 1;
        }
        
        .success-actions .btn::before {
            content: "";
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
            transition: 0.5s;
            z-index: -1;
        }
        
        .success-actions .btn:hover::before {
            left: 100%;
        }
        
        /* 动画效果 */
        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        @keyframes successPop {
            0% {
                transform: scale(0);
                opacity: 0;
            }
            60% {
                transform: scale(1.1);
                opacity: 1;
            }
            100% {
                transform: scale(1);
            }
        }
        
        @keyframes pulse {
            0% {
                transform: translate(-50%, -50%) scale(1);
                opacity: 0.15;
            }
            70% {
                transform: translate(-50%, -50%) scale(1.2);
                opacity: 0;
            }
            100% {
                transform: translate(-50%, -50%) scale(1);
                opacity: 0;
            }
        }
        
        /* 响应式设计 */
        @media (max-width: 1024px) {
            .page-title {
                font-size: 2.25rem;
            }
        }
        
        @media (max-width: 768px) {
            .page-title {
                font-size: 2rem;
            }
            
            .success-card {
                padding: 2.5rem 1.5rem;
            }
            
            .success-icon {
                font-size: 5rem;
            }
            
            .success-title {
                font-size: 1.6rem;
            }
            
            .success-actions {
                flex-direction: column;
                align-items: center;
                gap: 0.75rem;
            }
            
            .success-actions .btn {
                width: 100%;
                max-width: 300px;
            }
        }
        
        @media (max-width: 480px) {
            .page-header {
                padding: 1.5rem 0;
            }
            
            .page-title {
                font-size: 1.75rem;
            }
            
            .page-subtitle {
                font-size: 1rem;
            }
            
            .success-card {
                padding: 2rem 1rem;
            }
            
            .success-icon {
                font-size: 4rem;
            }
            
            .success-title {
                font-size: 1.4rem;
            }
            
            .success-message {
                font-size: 1rem;
            }
        }
    </style>
</head>
<body>
    <!-- 导航栏 -->
    <nav class="header-nav">
        <div class="nav-container">
            <a href="../index.jsp" class="nav-brand">
                🛒 购物网
            </a>
            
            <!-- 搜索框 -->
            <div style="flex: 1; max-width: 400px; margin: 0 20px; position: relative;">
                <input type="text" placeholder="搜索商品..." style="width: 100%; padding: 10px 15px; padding-right: 40px; border-radius: var(--border-radius); border: 1px solid var(--gray-300); transition: var(--transition);">
                <button style="position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--gray-500); cursor: pointer; font-size: 1.2rem;">
                    🔍
                </button>
            </div>
            <ul class="nav-links">
                <li><a href="../index.jsp">首页</a></li>
                <li><a href="../products/list.jsp">商品浏览</a></li>
                <li><a href="../view/cart.jsp">购物车</a></li>
                <% if (currentUser != null) { %>
                    <li><a href="../admin/user_info.jsp">用户中心</a></li>
                <% } %>
            </ul>
            <div class="user-actions">
                <% if (currentUser != null) { %>
                    <span class="user-info">欢迎, <%= currentUser.getUsername() %>!</span>
                    <a href="../auth/logout.jsp" class="btn btn-outline">退出</a>
                <% } else { %>
                    <a href="../auth/login.jsp" class="btn btn-outline">登录</a>
                    <a href="../auth/register.jsp" class="btn" style="margin-left: 10px;">注册</a>
                <% } %>
            </div>
        </div>
    </nav>
    <!-- 页面头部 -->
    <div class="page-header">
        <div class="container">
            <h1 class="page-title">订单支付成功</h1>
            <p class="page-subtitle">感谢您的购买，期待下次为您服务！</p>
            <div class="breadcrumb">
                <a href="../index.jsp">首页</a>
                <span>/</span>
                <a href="../view/cart.jsp">购物车</a>
                <span>/</span>
                <a href="../view/checkout.jsp">确认订单</a>
                <span>/</span>
                <span>支付成功</span>
            </div>
        </div>
    </div>
    
    <div class="container">
        <div class="success-card">
            <div class="success-icon">✓</div>
            <h2 class="success-title">订单支付成功！</h2>
            <p class="success-message">您的订单 <span class="order-id">#<%= orderId %></span> 已经支付成功。</p>
            <p class="success-subtext">感谢您的购买，我们会尽快为您发货。</p>
            
            <div class="success-actions">
                <a href="../index.jsp" class="btn">继续购物</a>
                <a href="../admin/user_info.jsp" class="btn btn-outline">查看订单详情</a>
            </div>
        </div>
    </div>
    
    <!-- 页脚 -->
    <footer class="footer">
        <div class="container">
            <div class="footer-top">
                <div>
                    <a href="../index.jsp" class="footer-logo">🛒 购物网</a>
                    <p style="margin-top: 1rem; color: var(--gray-400); font-size: 0.9rem;">
                        优质商品，优质服务，打造您的理想购物体验。
                    </p>
                </div>
                
                <div>
                    <h4 class="footer-heading">快速链接</h4>
                    <ul class="footer-links">
                        <li><a href="../index.jsp">首页</a></li>
                        <li><a href="../products/list.jsp">商品浏览</a></li>
                        <li><a href="#">关于我们</a></li>
                        <li><a href="#">联系我们</a></li>
                    </ul>
                </div>
                
                <div>
                    <h4 class="footer-heading">客户服务</h4>
                    <ul class="footer-links">
                        <li><a href="#">帮助中心</a></li>
                        <li><a href="#">售后政策</a></li>
                        <li><a href="#">配送信息</a></li>
                        <li><a href="#">常见问题</a></li>
                    </ul>
                </div>
            </div>
            
            <div class="footer-bottom">
                <p>&copy; 2025 购物网. 保留所有权利.</p>
            </div>
        </div>
    </footer>
    
    <script>
        // 页面加载完成后，可以添加一些额外的交互效果
        document.addEventListener('DOMContentLoaded', function() {
            // 模拟通知用户订单已生成
            setTimeout(function() {
                // 如果需要，可以在这里添加通知功能
            }, 1500);
        });
    </script>
</body>
</html>